

<%@ page import= "com.google.gdata.client.http.AuthSubUtil"%>
<%@ page import= "com.google.gdata.util.AuthenticationException"%>

<%@ page import= "com.google.gdata.client.docs.*"%>
<%@ page import= "com.google.gdata.data.docs.*"%>
<%@ page import= "com.google.gdata.data.acl.*"%>
<%@ page import= "com.google.gdata.util.*"%>

<%@ page import= "com.google.gdata.data.docs.DocumentListEntry"%>
<%@ page import= "com.google.gdata.data.docs.DocumentEntry"%>
<%@ page import= "com.google.gdata.data.docs.DocumentListFeed"%>

<%@ page import= " import java.io.PrintWriter"%>

<%@ page import= "java.io.File"%>
<%@ page import= "java.net.URL" %>
<%@ page import= "java.io.IOException"%>
<%@ page import= "java.net.MalformedURLException"%>
<%@ page import= "javax.servlet.http.*" %>
<%@ page import= "javax.servlet.http.HttpSession" %>

<%
        String requestUrl = AuthSubUtil.getRequestUrl("http://localhost:8084/webapp/lista.jsp",
                "http://docs.google.com/feeds/", false, true);
        //String suggestAuthorization = "<p>Este Aplicativo Precisa acessar sua Conta Google. " + "Para autorizar, <a href=\"" + requestUrl + "\"> acesse sua conta</a>.</p>";

        DocsService client = new DocsService("yourCo-yourAppName-v1");
                public DocumentListEntry uploadFile(String filepath, String title) throws IOException, ServiceException {

        File file = new File(filepath);
        DocumentListEntry newDocument = new DocumentListEntry();
        String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
        newDocument.setFile(new File(filepath), mimeType);
        newDocument.setTitle(new PlainTextConstruct(title));}

        return client.insert(new URL("http://docs.google.com/feeds/documents/private/full/"), newDocument);

        DocumentListEntry uploadedEntry = uploadFile("/path/to/your/file.doc", "TitleToUse");
        System.out.println("Document now online @ :" + uploadedEntry.getHtmlLink().getHref());
        String singleUseToken = AuthSubUtil.getTokenFromReply(request.getQueryString());
        String sessionToken = AuthSubUtil.exchangeForSessionToken(singleUseToken, null);


    }
%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>
